package com.baizhi.wd.action;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.baizhi.wd.entity.Person;
import com.baizhi.wd.service.TelbookService;
import com.baizhi.wd.service.TelbookServiceImpl;



public class UpdateQueryOneAction extends HttpServlet {
	public void service(HttpServletRequest request, HttpServletResponse response) throws IOException{
		try{
			//1获取client信息
			request.setCharacterEncoding("utf-8");
			String str = request.getParameter("id");
			int id = Integer.parseInt(str); 
			//2调用业务类的方法，实现根据id查一个的功能
			TelbookService ts = new TelbookServiceImpl();
			Person onePerson = ts.getOnePerson(id);
			//3.跳转--请求转发
			request.setAttribute("Person", onePerson);
			
			RequestDispatcher rd = request.getRequestDispatcher("/per/updateQueryOneView");
			rd.forward(request, response);
			return;
		}catch(Exception e){
			response.sendRedirect("/telbook_2/catchError.html");
			e.printStackTrace();	
		}
	}
}
